<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Tasks List</title>
</head>
<body>
    <h1>Tasks List</h1>
    <form id="editForm" method="POST" action="/update_task">
        <table border="1">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Dispatch Code</th>
                    <th>Task ID</th>
                    <th>Task Name</th>
                    <th>Task Frequency</th>
                    <th>Task Status</th>
                    <th>SQL ID</th>
                    <th>Execute Database ID</th>
                    <th>Receive Service ID</th>
                    <th>Storage Database ID</th>
                    <th>Storage Table ID</th>
                    <th>Comment</th>
                    <th>Create Time</th>
                    <th>Update Time</th>
                    <th>Delete Time</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                {% for task in tasks %}
                <tr>
                    <td>{{ task['id'] }}</td>
                    <td><input type="text" name="dispatch_code[{{ loop.index }}]" value="{{ task['dispatch_code'] }}"></td>
                    <td><input type="text" name="task_id[{{ loop.index }}]" value="{{ task['task_id'] }}"></td>
                    <td><input type="text" name="task_name[{{ loop.index }}]" value="{{ task['task_name'] }}"></td>
                    <td><input type="text" name="task_frequency[{{ loop.index }}]" value="{{ task['task_frequency'] }}"></td>
                    <td><input type="text" name="task_status[{{ loop.index }}]" value="{{ task['task_status'] }}"></td>
                    <td><input type="text" name="sql_id[{{ loop.index }}]" value="{{ task['sql_id'] }}"></td>
                    <td><input type="text" name="execute_database_id[{{ loop.index }}]" value="{{ task['execute_database_id'] }}"></td>
                    <td><input type="text" name="receive_service_id[{{ loop.index }}]" value="{{ task['receive_service_id'] }}"></td>
                    <td><input type="text" name="storage_database_id[{{ loop.index }}]" value="{{ task['storage_database_id'] }}"></td>
                    <td><input type="text" name="storage_table_id[{{ loop.index }}]" value="{{ task['storage_table_id'] }}"></td>
                    <td><input type="text" name="comment[{{ loop.index }}]" value="{{ task['comment'] }}"></td>
                    <td>{{ task['create_time'] }}</td>
                    <td>{{ task['update_time'] }}</td>
                    <td>{{ task['delete_time'] }}</td>
                    <td><button type="submit" name="task_id" value="{{ task['id'] }}">Save</button></td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </form>

    <script>
        document.getElementById("editForm").addEventListener("submit", function(event) {
            event.preventDefault();
            // 你可以在这里添加更多的客户端验证逻辑
            this.submit();
        });
    </script>
</body>
</html>
